﻿using BenCaoXuan.Infrastructure.Attr;
using BenCaoXuan.Infrastructure.Dto;
using BenCaoXuan.Service.Interface.middle;
using Microsoft.AspNetCore.Mvc;

namespace BenCaoXuan.Api.Admin.Controllers.middle
{
    [ApiGroup("Middle(移动端模块)")]
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ArticleController : ControllerBase
    {
        private readonly I_Article_Service _article_Service;

        public ArticleController(I_Article_Service article_Service)
        {
            _article_Service = article_Service;
        }
        /// <summary>
        /// 增加文章浏览量
        /// </summary>
        /// <param name="articleId"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Article_LookCount([FromBody] string articleId)
        {
            var result = await _article_Service.Article_LookCount(articleId);
            return Ok(result);
        }
        /// <summary>
        /// 获取所有文章数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_AllArticles()
        {
            var result= await _article_Service.Get_AllArticles();
            return Ok(result);
        }
        /// <summary>
        /// 获取文章详情
        /// </summary>
        /// <param name="articleId">文章ID</param>
        /// <returns>包含操作结果的DTO</returns>
        [HttpPost]
        public async Task<IActionResult> Get_ArticleDetails([FromBody] string articleId)
        {
            var result = await _article_Service.Get_ArticleDetails(articleId);
            return Ok(result);
        }
    }
}
